import api from '../../api'
import app from './app'
import axios from "axios"
const cart = {
  state: {
    accesories: {}, // 初始化各辅料选项
    orderInfo: {}
  },

  getters: {
    getAccesories: state => state.accesories,
    getOrderInfo: state => state.orderInfo
  },

  mutations: {
    setAccesories (state, data) {
      state.accesories = data
    },
    setOrderInfo (state, data) {
      state.orderInfo = data
    }
  },

  actions: {
    fetchAccesories ({ commit }, data) {
      axios.get(api.shoppingCart.initialAccesories, {params: {model: data}})
        .then(res=>{
          commit('setAccesories', res.data.data)
        })
    },
    fetchOrderInfo ({ commit }, data) {
      commit('setOrderInfo', data)
    }
    
  }
}

export default cart
